layui.use(['form', 'admin', 'ax','laydate'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var laydate = layui.laydate;

    //让当前iframe弹层高度适应
    admin.iframeAuto();

    //表单提交事件 通过
    form.on('submit(viaSubmit)', function (data) {
        var index;
        $.ajax({
        	url:Feng.ctxPath + "/orderTransport/audit?whether="+1,
        	cache: false,
        	dataType:"json",
        	data:data.field,
        	beforeSend:function(){
            	//弹出加载中
        		index = layer.load(1, {
                    shade: [0.3,'#000'] //0.1透明度的白色背景
                });
        	},
        	success:function(data){
            	layer.close(index); 
            	var Indexs = parent.layer.getFrameIndex(window.name);
                parent.layer.close(Indexs);
                Feng.success("更新成功！");
        	},
        	error:function(data){
            	layer.close(index); 
            	var Indexs = parent.layer.getFrameIndex(window.name);
                parent.layer.close(Indexs);
                Feng.error("更新失败！" + data.responseJSON.message)
        	}
        })
        return false;
    });

    //表单提交事件 驳回
    form.on('submit(rejectSubmit)', function (data) {
        var ajax = new $ax(Feng.ctxPath + "/orderTransport/audit?whether="+2, function (data) {
            Feng.success("更新成功！");
        	var Index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(Index);
        }, function (data) {
            Feng.error("更新失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();
        return false;
    });
    
    form.verify({
    	auditnode: function(value, item){ //value：表单的值、item：表单的DOM对象
    	    if(value.length>255){
    	    	alert(value.length)
    	    	return '字数超出255';
    	    }
    	  }
    });

    //返回按钮
    $("#backupPage").click(function () {
    	var Index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(Index);
    });

});